package com.briup.day05;

import java.util.Random;
import java.util.Scanner;

public class Test_Random {
    public static void main01(String[] args) {
        Random random = new Random();
        for (int i = 0; i < 10; i++) {
            int num = random.nextInt(20 - 10 + 1) + 10;
            System.out.println(num);
        }
    }

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        //根据用户输入的和随机数比较
        Random random = new Random();
        int num1 = random.nextInt(100) + 1;
        while (true) {
            System.out.println("请输入1-100之间的随机数");
            int num = input.nextInt();
            if (num > num1) {
                System.out.println("猜大了");
            }else if(num<num1) {
                System.out.println("猜小了");
            }else{
                System.out.println("猜对了！是"+num1);
                break;
            }
        }
    }
}
